﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EntityComponentSystem.Framework.Systems
{
    public interface IIntervalBehaviorSystem : IBehaviorSystem
    {
    }

    public class IntervalBehaviorSystem : BehaviorSystem, IIntervalBehaviorSystem
    {
        public float Interval { get; set; }
        public float NextInterval { get; private set; }

        public IntervalBehaviorSystem(string name, float interval)
        {
            this.Name = name;
            this.Interval = interval;
            this.NextInterval = interval;
        }

        public override void Update(GameEngine ge)
        {
            NextInterval -= ge.TimeSinceLastFrame;
            if (NextInterval <= 0f)
            {
                NextInterval = Interval;
                base.Update(ge);
            }
        }
    }

}
